<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %> 
<%@taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt-rt"%>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt"%>
<%@	page import="com.yaodian100.core.common.utils.ServerValue"%>
<c-rt:set var="midHostName" value='<%=ServerValue.getMidHostname()%>'/>
<c-rt:set var="midContextPath" value='<%=ServerValue.getMidContextPath()%>'/>
<style type="text/css" media="screen">
<!-- 
   select.selCont{ margin: 10px; width: 200px; }
   select.selCont1{ margin: 10px; width: 800px; }
-->
</style>
<script type="text/javascript" charset="UTF-8" src="/js/jquery.checkboxes.js"></script>
<!-- 数字验证 -->
<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
<script type="text/javascript" charset="UTF-8" src="/js/yaodian100.common.js"></script>
<script type="text/javascript"> 
	$(function() {
	 $("#loadingImg").dialog({
		  title: '资料载入中',
			bgiframe: true,
			autoOpen: false,
			height: 150,
			width:280,
			modal: true
		});			
		//点选清除button
		$("#clearDataContext").click(function(){
			clear_form_elements();
		});
		//点选加入button
		$("#addSelect").click(function(){
			 if ($("#selectMainCategoryText").text() == "" ){
					alert("请选择目录");
					return false;
			}
			$("#editFlag").val("true");
			var addOnDataText = $("#selectMainCategoryText").text() + ",[]" + "," +$("#addonPath").val();
			var addOnDataValue = "";
			if ( $("#addonId").val() != ""){
				if ( !duplicateCategoryIsExist() ){//判断是否加入重复的目录
					if ( $("#isEndNode").val() == "Y"){//判断此目录是否为最底层
						addOnDataValue=$("#addonId").val() + "," + $("#addonPath").val() + ",101";
						$('#addOnSelect').append($("<option></option>").attr("value",addOnDataValue).text(addOnDataText));
						clear_form_elements();
					}else alert("请选择最底层的目录");
				}else alert("请勿加入重复的目录");
			}
		});

		//編輯時select選取反白要修改的商品
		if($("#addonId").val()!=""){
			$('#addOnSelect option').each(function(){		
				if(this.value.split(",")[0]==$("#addonId").val()){	
					$(this).attr("selected","true"); 
				}									
			});
		}
		
		//移除select的商品	
		$("#removeSelect").click(function(){
			var sel = $("#addOnSelect option:selected");
			//主目錄被移除時
			if($(sel).val().split(",")[0]=="${product.mainCategoryID}"){	
				$("#editFlag").val("true");
			}									
			$(sel).remove();								
		});		
	
		//点选select里的item，自动将资料带到上方的栏位中
		$("#addOnSelect").click(function(){	
			var sel = $("#addOnSelect option:selected");
			$("#addonId").val($(sel).val().split(",")[0]);		
			$("#addonPath").val($(sel).val().split(",")[1]);	
			$("#addonShowSeq").val($(sel).val().split(",")[2]);	
			$("#selectMainCategoryText").text("");	
			$("#selectMainCategoryText").text($(sel).text().split(",")[0]);
			if ( checkPermission($("#addonPath").val())){
				loadDefaultCategory();
				$("#addSelect").css("display","inline-block");
			}else{
				$("#addSelect").css("display","none");
				alert("抱歉你无权限编辑该目录，若要移除请按移除钮");
			}		
		});	
		$("#submit_button").click(function(){
			var addData="";	
			var nonePermission = "";			
			$('#addOnSelect option').each(function(){
				if ( checkPermission($(this).text().split(",")[2]) ){
					nonePermission = nonePermission + $(this).val().split(",")[0];
				}
				addData = addData + $(this).val().split(",")[0] + "," + $(this).text().split(",")[0] + "," + $(this).val().split(",")[2] + ";";																			
			});
			if (addData == "" ){
				alert("请选择商品目录");
				return false;
			}
			$("#finalAddOnData").val(addData);
			var tempArray = addData.split(";");
			$("#categoryDialog").html("");
			for( var i = 0 ; i < tempArray.length-1; i++ ){
				var tempSplit = tempArray[i].split(",");
				if ( "${mainCategory}" == tempSplit[0] )
					$("#categoryDialog").append("<input type='checkbox' id='changeMainCategory_" + i + "' name='changeMainCategory' value='" + tempSplit[0] + "' checked='checked'/>设为主目录,");
				else{
					if ( nonePermission.indexOf(tempSplit[0]) == -1 ){
						$("#categoryDialog").append("X无此权限设为主目录,");
					}else{
						$("#categoryDialog").append("<input type='checkbox' id='changeMainCategory_" + i + "' name='changeMainCategory' value='" + tempSplit[0] + "'/>设为主目录,");
					}
				}
				$("#categoryDialog").append(tempSplit[1] + "<br/>");
				if ( "" != "${mainCategory}" ) $("#lastMainCategoryId").val("${mainCategory}");
			}
			if ( "" != $("#editFlag").val()){ 
				$("#categoryDialog").append("<input type='button' name='d_ok' id='d_ok' value='确定'/>&nbsp;&nbsp;");
				$("#categoryDialog").append("<input type='button' name='d_cancel' id='d_cancel' value='取消'/>");
				$("#categoryDialog").dialog({
					title:"请选择主分類",
					bgiframe: true,
					autoOpen: false,
					height: 400,
					width:600,
					modal: true
				});
				$.radioCheckboxGroup("changeMainCategory");	
				$("#categoryDialog").dialog('open');

				$("input[id*=changeMainCategory_]").click(function(){
					if ( $(this).attr("checked"))
						$("#lastMainCategoryId").val($(this).val());
				});
				$("#d_ok").click(function(){
					if ( $("#lastMainCategoryId").val() == "" ){
						alert("请选择主分類");
					}else{
						$('#categoryDialog').dialog('destroy');
						$("#categoryDialog").dialog('close');
						$("#categoryConfigForm").submit();
					}	
				});	
				$("#d_cancel").click(function(){
					$('#categoryDialog').dialog('destroy');
					$("#categoryDialog").dialog('close');	
					return false;
				});	
			}else $("#categoryConfigForm").submit();
		});
		
		//第0层
		$("#categorySelect").click(function(){
			if ( null != $(this).val()  ){
				$("#addSelect").css("display","inline-block");
				$.ajax({
				    url: '${midContextPath}/category/getProductCategory.do',
				    type: 'post',
				    dataType: 'json',
				    data: {categoryid:$(this).val(), callback: 'elementSelectCallback'},
				    cache: false,
				    beforeSend: function(xhr) {
							$("#loadingImg").dialog("open");
							$('#elementSelect').find('option').remove().end();
					   	$('#attributeSelect').find('option').remove().end();
					   	$('#itemSelect').find('option').remove().end();
					   	$('#unitSelect').find('option').remove().end();
					   	$('#listSelect').find('option').remove().end();						
				    },
				    success: function( strData ){
				    	$("#loadingImg").dialog("close");
				    	elementSelectCallback(strData);
					}
				});	   						
				//$.post("${midContextPath}/category/getProductCategory.do",{categoryid:$(this).val()},elementSelectCallback,"json");
				$("#addonId").val($(this).val());
				$("#selectMainCategoryText").val("");
				getCategoryPath();
			}
		});
		//第1层
		$("#elementSelect").click(function(){
			if ( null != $(this).val()  ){
				$.ajax({
				    url: '${midContextPath}/category/getProductCategory.do',
				    type: 'post',
				    dataType: 'json',
				    data: {categoryid:$(this).val(), callback: 'attributeSelectCallback'},
				    cache: false,
				    beforeSend: function(xhr) {
							$("#loadingImg").dialog("open");
							$('#attributeSelect').find('option').remove().end();
						  $('#itemSelect').find('option').remove().end();
						  $('#unitSelect').find('option').remove().end();
						  $('#listSelect').find('option').remove().end();						
				    },
				    success: function( strData ){
				    	$("#loadingImg").dialog("close");
				    	attributeSelectCallback(strData);
					}
				});			  	
				//$.post("${midContextPath}/category/getProductCategory.do",{categoryid:$(this).val()},attributeSelectCallback,"json");
				$("#addonId").val($(this).val());
				$("#selectMainCategoryText").val("");
				getCategoryPath();
			}
		});
		//第2层
		$("#attributeSelect").click(function(){
			if ( null != $(this).val()  ){
				$.ajax({
				    url: '${midContextPath}/category/getProductCategory.do',
				    type: 'post',
				    dataType: 'json',
				    data: {categoryid:$(this).val(), callback: 'itemSelectCallback'},
				    cache: false,
				    beforeSend: function(xhr) {
							$("#loadingImg").dialog("open");
						  $('#itemSelect').find('option').remove().end();
						  $('#unitSelect').find('option').remove().end();
						  $('#listSelect').find('option').remove().end();						
				    },
				    success: function( strData ){
				    	$("#loadingImg").dialog("close");
				    	itemSelectCallback(strData);
					}
				});		  	
				//$.post("${midContextPath}/category/getProductCategory.do",{categoryid:$(this).val()},itemSelectCallback,"json");
				$("#addonId").val($(this).val());
				$("#selectMainCategoryText").val("");
				getCategoryPath();
			}
		});
		//第三层
		$("#itemSelect").click(function(){
			if ( null != $(this).val()  ){
				$.ajax({
				    url: '${midContextPath}/category/getProductCategory.do',
				    type: 'post',
				    dataType: 'json',
				    data: {categoryid:$(this).val(), callback: 'unitSelectCallback'},
				    cache: false,
				    beforeSend: function(xhr) {
							$("#loadingImg").dialog("open");
						  $('#unitSelect').find('option').remove().end();
						  $('#listSelect').find('option').remove().end();						
				    },
				    success: function( strData ){
				    	$("#loadingImg").dialog("close");
				    	unitSelectCallback(strData);
					}
				});		  	
				//$.post("${midContextPath}/category/getProductCategory.do",{categoryid:$(this).val()},unitSelectCallback,"json");
				$("#addonId").val($(this).val());
				$("#selectMainCategoryText").val("");
				getCategoryPath();
			}
		});
		//第四层
		$("#unitSelect").click(function(){
			if ( null != $(this).val()  ){
				$.ajax({
				    url: '${midContextPath}/category/getProductCategory.do',
				    type: 'post',
				    dataType: 'json',
				    data: {categoryid:$(this).val(), callback: 'listSelectCallback'},
				    cache: false,
				    beforeSend: function(xhr) {
							$("#loadingImg").dialog("open");
							$('#listSelect').find('option').remove().end();						
				    },
				    success: function( strData ){
				    	$("#loadingImg").dialog("close");
				    	listSelectCallback(strData);
					}
				});			  	
				//$.post("${midContextPath}/category/getProductCategory.do",{categoryid:$(this).val()},unitSelectCallback,"json");
				$("#addonId").val($(this).val());
				$("#selectMainCategoryText").val("");
				getCategoryPath();
			}
		});
		//第五层
		$("#listSelect").click(function(){
			//$.post("${midContextPath}/category/getProductCategory.do",{categoryid:$(this).val()},unitSelectCallback,"json");
			$("#addonId").val($(this).val());
			$("#selectMainCategoryText").val("");
			getCategoryPath();
			combineCategoryPath();
			checkIsEndNodex();
		});				
	});
	function getCategoryPath(){
		$.getJSON("${midContextPath}/pickProduct/findCategoryPath.do",{categoryId:$("#addonId").val()},categoryPathCallback);
	}
	function categoryPathCallback(jsonCategoryPath){
		$("#addonPath").val(jsonCategoryPath);
	}
	//判断是否有重复目录
	function duplicateCategoryIsExist(){
		var result = false;		
		$('#addOnSelect option').each(function(){		
			if( $(this).val().split(",")[0] == $("#addonId").val()){	
				result = true;
			}									
		});	
		return result;
	}
	function loadDefaultCategory(){
		$('#elementSelect').find('option').remove().end();
   	$('#attributeSelect').find('option').remove().end();
   	$('#itemSelect').find('option').remove().end();
   	$('#unitSelect').find('option').remove().end();
   	$('#listSelect').find('option').remove().end();
		//load default value
		var tempId = $("#addonPath").val().split("/");
		$("#categorySelect").val(tempId[0]).attr("selected","selected");
		$.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[0]},elementSelectCallback,"json");
	}
	//清空输入栏位
	function clear_form_elements(){
			$('#elementSelect').find('option').remove().end();
	   	$('#attributeSelect').find('option').remove().end();
	   	$('#itemSelect').find('option').remove().end();
	   	$('#unitSelect').find('option').remove().end();
	   	$('#listSelect').find('option').remove().end();
			ele = $("#categoryConfigForm");
	    $(ele).find(':input').each(function() {
	        switch(this.type) {
	            case 'password':
	            case 'select-multiple':
	            case 'select-one':
	            case 'text':
	            case 'textarea':
                $(this).val('');
                break;
	            case 'checkbox':
	            case 'radio':
	                this.checked = false;
	        }
	    }); 
			$("#selectMainCategoryText").text("");
	}	
	
	//判断是否为最底层
 	function checkIsEndNodex(){
  	$.post("${midContextPath}/pickProduct/getJsonCategoryData.do",{mainCategoryId : $("#addonId").val()},endNodeCallback,"json");
 	}	
 	function endNodeCallback(categoryResult){
 			$("#isEndNode").val(categoryResult);
 	} 	

	function elementSelectCallback(categories){
		if ( "" != $("#addonPath").val()){
			var tempId = $("#addonPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		} 
				if ( categories[i].id == tempId[1] ){
					$('#elementSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#elementSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 1 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[1]},attributeSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		} 
				$("#isEndNode").val(categories[i].isEndnode);
				$('#elementSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
		checkIsEndNodex();
	}
	function attributeSelectCallback(categories){
		if ( "" != $("#addonPath").val()){
			var tempId = $("#addonPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		} 
				if ( categories[i].id == tempId[2] ){
					$('#attributeSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#attributeSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 2 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[2]},itemSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		} 
				$("#isEndNode").val(categories[i].isEndnode);
				$('#attributeSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
		checkIsEndNodex();
	}
	function itemSelectCallback(categories){
		if ( "" != $("#addonPath").val()){
			var tempId = $("#addonPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		} 
				if ( categories[i].id == tempId[3] ) {
					$('#itemSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#itemSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 3 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[3]},unitSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		} 
				$("#isEndNode").val(categories[i].isEndnode);
				$('#itemSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
		checkIsEndNodex();
	}
	function unitSelectCallback(categories){
		if ( "" != $("#addonPath").val()){
			var tempId = $("#addonPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		} 
				if ( categories[i].id == tempId[4] ) {
					$('#unitSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#unitSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
			if ( tempId.length-1 > 4 ) $.post("${midContextPath}/category/getProductCategory.do",{categoryid:tempId[4]},listSelectCallback,"json");
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		} 
				$("#isEndNode").val(categories[i].isEndnode);
				$('#unitSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
		checkIsEndNodex();
	}
	function listSelectCallback(categories){
	  $('#listSelect').find('option').remove().end();		
		if ( "" != $("#addonPath").val()){
			var tempId = $("#addonPath").val().split("/");
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		} 
				if ( categories[i].id == tempId[5] ) {
					$('#listSelect').append($("<option selected='selected'></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
					$("#isEndNode").val(categories[i].isEndnode);
				}else
					$('#listSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}else{
			for( var i = 0 ; i < categories.length; i++ ){
				var cmark='';
        		if(categories[i].isBrand=="Y"){
        			cmark=cmark+'○';//品牌
        		}
        		 if(categories[i].isPromotion=="Y"){
        			 cmark=cmark+'◎';//活動
        		} 
				$("#isEndNode").val(categories[i].isEndnode);
				$('#listSelect').append($("<option></option>").attr("value",categories[i].id).text(cmark+categories[i].name+'('+categories[i].id+')'));
			}
		}
		combineCategoryPath();
		checkIsEndNodex();
	}			
	//组合目录路径
	function combineCategoryPath(level){
		var categoryTemp = $('#categorySelect option:selected').text(); 
		var elementTemp =  $('#elementSelect option:selected').text();
		var attributeTemp = $('#attributeSelect option:selected').text();
		var itemTemp = $('#itemSelect option:selected').text();
		var unitTemp = $('#unitSelect option:selected').text();
		var listTemp = $('#listSelect option:selected').text();
		var textTemp ;
		if ( "" != categoryTemp ) textTemp = categoryTemp;
		if ( "" != elementTemp ) textTemp = textTemp + " > " +  elementTemp;
		if ( "" != attributeTemp ) textTemp = textTemp + " > " +  attributeTemp;
		if ( "" != itemTemp ) textTemp = textTemp + " > " +  itemTemp;
		if ( "" != unitTemp ) textTemp = textTemp + " > " +  unitTemp;
		if ( "" != unitTemp ) textTemp = textTemp + " > " +  listTemp;
		$("#selectMainCategoryText").html(textTemp);
	}	
	//判斷目錄使用權限
	function checkPermission(categoryPath){
		var permissions = $("#userPermissions").val().split(",");
		var rootId = categoryPath.split("/")[0];
		var result = false;
		for( i = 0 ; i < permissions.length; i++ ){
			if ( trim(permissions[i]) == trim(rootId)){
				result = true;
				break;
			}
		}
		return result;
	}
</script>
<style type="text/css">
.msg{float:left; line-height:1em; margin:0; display:block;border:1px solid #f66;padding:2px 5px;*padding:2px 5px 1px;}
.msg.rn{background-color:#fff2f2;border-color:#f66;}
</style>
<h1>N选M商品管理-分类管理
<div class="f-link">
	<a href="${midContextPath}/pickProduct/search.do">回列表页</a>
</div>
</h1>
<s:if test="hasActionErrors()">
	<s:actionerror cssClass="msg rn"/>
</s:if>
<s:if test="hasActionMessages()">
	<s:actionmessage cssClass="msg rn"/>
</s:if>
<p></p>
<c-rt:if test="${not empty product.productId or not empty shelf.shelfId}">
	<jsp:include page="commonMenu.jsp"/>
</c-rt:if>
<s:form action="saveCategoryConfig.do" id="categoryConfigForm" method="post">
<table class="tb-data" width="100%">
	<tr>
		<th>商品编号</th>
		<td>${product.productId}</td>
	</tr>
	<tr>
		<th>商品名称</th>
		<td>${product.productName}</td>
	</tr>
	<tr>
		<th>* 所有分类列表</th>
		<td>
			<span class="txt-rd">○符号表示该分类为品牌;◎表活動</span><br/>
			<select id="categorySelect" name="categoryid" size="5" class="selCont">
        	<c-rt:forEach items="${rootCategories}" var="category">
					<option value="${category.id}">${category.name}(${category.id})</option>
				</c-rt:forEach>
       </select>       
       <select id="elementSelect" name="categoryid" size="5" class="selCont"></select>
       <select id="attributeSelect" name="categoryid" size="5" class="selCont"></select>
       <br/>
       <select id="itemSelect" name="categoryid" size="5" class="selCont"></select>
       <select id="unitSelect" name="categoryid" size="5" class="selCont"></select>
       <select id="listSelect" name="categoryid" size="5" class="selCont"></select>
       <br/>
                        选取的分类为：<span id="selectMainCategoryText"></span>
       <br/>
		</td>
	</tr>		
	<tr>
		<td colspan="2">
		<div class="f-link">
			<a href="javascript:void(0);" id="clearDataContext">清除</a>	
			<!-- <a href="javascript:void(0);" id="editedToSelect">修改</a> -->
			<a href="javascript:void(0);" id="addSelect">加入</a>
			<a href="javascript:void(0);" id="removeSelect">移除</a>
		</div>
	</tr>
	<tr>
		<th>* 所属分类列表</th>
		<td>
			主分类为：<span>${mainCategoryText}</span><br/>
			<!-- 新增時顯示的select -->
			<select id="addOnSelect" name="addOnSelect" size="10" class="selCont1">
				<c-rt:forEach items="${productCategories}" var="productCategory">
					<option value="${productCategory.categoryId},${fn:split(productCategoryMap[productCategory.categoryId],',')[1]},${fn:split(productCategoryMap[productCategory.categoryId],',')[2]}">${fn:split(productCategoryMap[productCategory.categoryId],',')[0]},[${productCategory.createUser}/${productCategory.createDate}/${productCategory.modifyUser}/${productCategory.modifyDate}],${fn:split(productCategoryMap[productCategory.categoryId],',')[1]}</option>
				</c-rt:forEach>
			</select>
			<br/>馆类别>分类1>分类2>分类3>分类4>分类5,[建立者/建立日期/修改者/修改日期],分类路径
		</td>
	</tr>		
	<tr>
		<td>
		<input type="hidden" id="editFlag" name="editFlag"/>
		<input type="hidden" id="addonId" name="addonId" value="" />
		<input type="hidden" id="addonPath" name="addonPath" value="" />
		<input type="hidden" id="addonShowSeq" name="addonShowSeq" value="" />
		<input type="hidden" id="isEndNode" name="isEndNode" value="" />
		<input type="hidden" name="productIdParam" value="${product.productId}" />
		<input type="hidden" name="shelfIdParam" value="${shelf.shelfId}" />
		<input type="hidden" name="lastMainCategoryId" id="lastMainCategoryId" value="" />
		<input type="hidden" name="finalAddOnData" id="finalAddOnData" value=""/>
		<input type="hidden" id="userPermissions" value="${userPermissions}"/>
		<input type="button" id="submit_button" value="储  存" />								
		</td>
	</tr>	
</table>
</s:form>
<div id="categoryDialog" style="display:none;"></div>
<div id="loadingImg" style="display:none;">
	<img src="/images/loading.gif"/>资料载入中,请稍候...
</div>